<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<?php echo HEADMETA; ?>
<script src="<?php echo RES;?>www_zeai_cn.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/m.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/ZeaiUP.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>select4.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo HOST;?>/cache/udata.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<link href="<?php echo RES;?>m/css/m.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<?php require_once 'm_style.php';?>
<link href="css/m_adm.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<style>
.tabmenufix {top:0;border-bottom:#f5f5f5 1px solid;padding-top:12px}
.gj_add{width:85%;margin:70px auto 200px auto;text-align:left;font-size:14px}
.gj_add dl{width:100%;margin:10px 0}
.gj_add dl dt{display:block;line-height:30px/*;color:<?php echo $_ADM['color'];?>*/}
.gj_add dl dd{display:block}
.RCW li{width:25%;float:left;text-align:left;color:#666}
</style>
</head>
<body>
<?php if($submitok == 'gj_list' || $submitok == 'gj_add' || $submitok == 'gj_mod'){
	$totalnum = $db->COUNT(__TBL_CRM_BBS__,"uid=".$uid);?>
    <div class="tabmenu tabmenu2 tabmenufix">
        <a href="crm_gj_yj.php?uid=<?php echo $uid;?>&submitok=gj_list"<?php echo ($submitok == 'gj_list' || $submitok == 'gj_mod')?' class="ed"':'';?>>跟进列表(<?php echo $totalnum;?>)</a>
        <a href="crm_gj_yj.php?uid=<?php echo $uid;?>&submitok=gj_add"<?php echo ($submitok == 'gj_add')?' class="ed"':'';?>>新增跟进</a>
    </div>
<?php }?>
<!--跟进列表-->
<?php 
if($submitok == 'gj_list'){
	if(!CRMQX('crm_bbs_view'))echo "<div class='nodataico'><i></i>暂无【客户跟进(查看)】功能</div>";
	$rt = $db->query("SELECT * FROM ".__TBL_CRM_BBS__." WHERE uid=".$uid." ORDER BY id DESC");
	$total = $db->num_rows($rt);
	if ($total <= 0 ) {
		echo "<div class='nodataico'><i class='ico'>&#xe608;</i>暂无信息<br><br><a class='btn size2 ico zeaibg' href='crm_gj_yj.php?submitok=gj_add&uid=".$uid."'>&#xe622; 新增跟进</a></div>";
	} else {?>
	<style>
	.table_gj{width:92%;margin:12px auto;border-collapse:collapse;box-shadow: 0 0 28px rgb(0 0 0 / 8%);border-radius:8px}
	.table_gj td{font-size:12px;color:#999}
	.table_gj td em{width:90%;font-size:13px;line-height:200%;color:#000;margin:5px 0 10px 0}
    .timebox{width:60px;height:60px;margin-left:12px;padding:12px 0 0 0;background-color:rgba(<?php echo c16_rgb($_ADM['color']);?>,.08);border-radius:2px;text-align:center;color:<?php echo $_ADM['color'];?>;position:relative;font-size:12px;box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;font-family:Arial, Helvetica, sans-serif}
    .timebox b{font-size:18px;margin-right:2px;}
    .timebox font{display:inline-block}
    .timebox .zj{width:0;height:0;left:60px;top:20px;position:absolute;border-top:10px solid transparent;border-bottom:10px solid transparent;border-left:10px solid rgba(<?php echo c16_rgb($_ADM['color']);?>,.08)}
	.pathlist img{margin:0 5px 2px 2px;width:50px;height:50px;object-fit:cover;-webkit-object-fit:cover;border-radius:2px}
	.table_gj td.CC{padding:10px 0 30px;word-break:break-all;word-wrap:break-word;line-height:180%;position:relative}
	.table_gj td .delico,.table_gj td .editico{position:absolute;bottom:12px;font-size:14px;color:#999}
	.table_gj td .editico{right:48px}
	.table_gj td .delico{right:12px}
	</style>
    <?php
    for($i=1;$i<=$total;$i++) {
        $rows = $db->fetch_array($rt,'name');
        if(!$rows) break;
        $id      = $rows['id'];
        $uid     = $rows['uid'];
        $addtime = '<b>'.YmdHis($rows['addtime'],'d').'</b>日<br><font>'.YmdHis($rows['addtime'],'Y').'/'.YmdHis($rows['addtime'],'m').'</font>';
        $content = '<em>'.dataIO($rows['content'],'out').'</em>';
        $admid   = $rows['admid'];
        $admname = dataIO($rows['admname'],'out');
        $nexttime   = intval($rows['nexttime']);
        $intention  = intval($rows['intention']);
        $nexttime_str  = ($nexttime>0)?'<br>下次联系：'.YmdHis($nexttime,'YmdHi'):'';
        $pathlist      = $rows['pathlist'];
        $medialist     = $rows['medialist'];
		$crm_ugrade=0;
		$row = $db->ROW(__TBL_USER__,"crm_ugrade","id=".$uid,"name");
		if ($row)$crm_ugrade = intval($row['crm_ugrade']);
		if ($crm_ugrade<1){
			$intention_str = '<br>售前意向：'.crm_arr_title($bbs_intentionARR,$intention);
		}else{
			$intention_str = '';
		}
		?><table class="table_gj"<?php echo ($i == 1)?' style="margin-top:70px"':'';?>>
		<tr>
		<td width="80" align="left" valign="top" style="padding:12px 0">
		<div class="timebox"><?php echo $addtime;?><div class="zj"></div></div>
		</td>
		<td width="10" align="left"></td>
		<td align="left" class="CC">
		<?php
			echo '跟进人：'.$admname.'（ID:'.$admid.'）'.$intention_str.$nexttime_str;
			echo $content;
            if(!empty($pathlist)){
                $ARR=explode(',',$pathlist);
                $pathlist=array();
				echo '<div class="pathlist">';
                foreach ($ARR as $V) {?>
					<a href="javascript:;" class="zoom" onClick="parent.parent.ZeaiM.piczoom('<?php echo smb(UP.$V,'b'); ?>');"><img src="<?php echo $_ZEAI['up2'].'/'.$V;?>"></a>
                    <?php
                }
				echo '</div>';
            }?>
			<?php if(CRMQX('crm_bbs_del') && ifmyu($uid)){?><a href="crm_gj_yj.php?submitok=gj_del_update&id=<?php echo $id;?>&uid=<?php echo $uid;?>&js=a" onclick="return confirm('确定删除？')" class="delico ico">&#xe779;</a><?php }?>
            <?php if(CRMQX('crm_bbs_mod') && ifmyu($uid)){?><a href="crm_gj_yj.php?submitok=gj_mod&id=<?php echo $id;?>&uid=<?php echo $uid;?>" title="修改" class="editico ico">&#xe610;</a><?php }?>
        </td>
		</tr></table>
	<?php }}?>
	<div class="blank"></div>
    <div id="backtop"><a id="btmTopBtn"><i class="ico">&#xe60c;</i>顶部</a></div>
    <script>document.body.onscroll = backtop_alone;</script>  
<!--跟进-新增-->
<?php }elseif ($submitok =='gj_add' || $submitok =='gj_mod'){
	if($submitok == 'gj_mod'){
		if(!CRMQX('crm_bbs_mod'))exit(noauth('暂无【跟进】修改功能'));
		if ( !ifint($id))alert_adm("跟进ID不正确","back");
		if ( !ifint($uid))alert_adm("客户UID不正确","back");
		$row = $db->ROW(__TBL_CRM_BBS__,"*","id=".$id,"name");
		if ($row){
			$content   = dataIO($row['content'],'out');
			$intention = $row['intention'];
			$uid       = $row['uid'];
			$nexttime  = $row['nexttime'];
			$nexttime = ($nexttime>0)?YmdHis($nexttime):'';
			$pathlist = $row['pathlist'];
		}
	}else{
		if(!CRMQX('crm_bbs_add'))exit(noauth('暂无【跟进】新增功能'));
		$intention=4;
	}
	if(!ifmyu($uid))exit(noauth('只有被分配的红娘才可以操作'));
	$row = $db->ROW(__TBL_USER__,"crm_ugrade,crm_ukind","id=".$uid,"name");
	if ($row){
		$crm_ugrade = intval($row['crm_ugrade']);
		$crm_ukind = intval($row['crm_ukind']);
	}else{
		alert_adm("客户不存在","back");
	}?>
    <form id="Www_zeai_cn_form" class="gj_add">
        <dl>
            <dt>下次联系</dt>
            <dd><input name="nexttime" id="nexttime" type="text" class="input size2 W100_ ico" maxlength="30" value="<?php echo $nexttime;?>"  autocomplete="off" placeholder="&#xe634; " /></dd>
        </dl>
        <dl>
            <dt>跟进内容<font class="Cf00">*</font></dt>
            <dd><textarea name="content" rows="4" class="textarea W100_" id="content" placeholder="如：【今天电话了对方，说过两天】【微信确认，客户说明天到我们公司面谈】【电话回访，这个月出差，下个月回来】等"><?php echo $content;?></textarea></dd>
        </dl>
        <dl>
            <dt>跟进截图<font class="S12 C999">（支持批量上传）</font></dt>
            <dd class="piclibox" id="piclibox">
                <ul><li class="ico">&#xe622;</li>
                <?php
                if(!empty($pathlist)){
                    $ARR=explode(',',$pathlist);
                    if (count($ARR) >= 1 && is_array($ARR)){foreach ($ARR as $V){echo '<li><img src="'.UP.$V.'"><b></b></li>';}}//><b class="ico">&#xe62c;</b>
                }
                ?>
                </ul>
            </dd>
        </dl>
        <div class="clear"></div>
        <?php if ($crm_ugrade<1){?>  
        <dl style="margin-top:0">
            <dt>售前意向</dt>
            <dd><script>zeai_cn__CreateFormItem('radio','intention','<?php echo $intention; ?>','class=" RCW"',<?php echo $_CRM['bbs_intention'];?>);</script></dd>
        </dl>
        <div class="clear"></div>
        <?php }else{?>
            <input name="intention" id="intention" type="hidden" value="<?php echo $intention;?>" />
        <?php }?>
        
        <?php if(CRMQX('crm_ukind')){?>
        <dl>
            <dt>客户分类</dt>
            <dd><script>var nulltext='';zeai_cn__CreateFormItem('select','crm_ukind','<?php echo $crm_ukind; ?>','class="size2 select W100_"',crm_ukind_ARR);</script></dd>
        </dl>        
		<?php }else{?>
			<input name="crm_ukind" id="crm_ukind" type="hidden" value="<?php echo $crm_ukind;?>" />
        <?php }?>

        <input name="uid" type="hidden" value="<?php echo $uid;?>" />
        <input name="pathlist" id="piclist" type="hidden" value="" />
        <?php if ($submitok == 'gj_mod'){?>
          <input name="submitok" type="hidden" value="gj_mod_update" />
          <input name="id" type="hidden" value="<?php echo $id;?>" />
        <?php }else{ ?>
          <input name="submitok" type="hidden" value="gj_add_update" />
        <?php }?>
    </form>
	<div class="savebtnbox"><button type="button" class="btn size3 zeaibg" id="save">提交保存</button></div>
	<script>
	var up2='<?php echo UP;?>',upMaxMB=<?php echo $_UP['upMaxMB']; ?>,maxnum=5,upurl='crm_gj_yj'+zeai.ajxext+'id=<?php echo $id;?>',browser='<?php echo browser();?>',uid=<?php echo $uid; ?>;
	top.uid=<?php echo $uid; ?>,top.upurl='crm_gj_yj'+zeai.ajxext+'id=<?php echo $id;?>';//ifrmae 重置变量
	ZeaiUP.more({wxtmp:false,obj:piclibox,submitokBef:'ajax_tmpB_',end:function(e){/*删除回调*/}});
	ZeaiUP.more_mod_init({libox:piclibox,formobj:o('piclist')});
    save.onclick=function(){
		<?php if ($crm_ugrade<1){?>
		if (!zeai.form.ifradio('intention')){
			zeai.msg('请选择【售前意向】');	
			return false;
		}
		<?php }?>
        if (zeai.empty(o('content').value)){
            zeai.msg('请输入【跟进内容】'+o('content').value,o('content'));	
            return false;
        }
		zeai.ajax({url:'crm_gj_yj'+zeai.extname,form:Www_zeai_cn_form},function(e){rs=zeai.jsoneval(e);
			zeai.msg(0);
			if(rs.flag==1){
				zeai.msg(rs.msg,{time:3});
				setTimeout(function(){zeai.openurl('crm_gj_yj'+zeai.ajxext+'submitok=gj_list&uid='+uid);},1000);
			}else{
				zeai.msg(rs.msg);
			}
		});
    }
    </script>
	<script src="laydate/laydate.js"></script><script>lay('#version').html('-v'+ laydate.v);laydate.render({elem:'#nexttime',type: 'datetime'});</script>
	<?php
}?>
